import { Component, OnInit ,ChangeDetectorRef } from '@angular/core';

import { CommonService } from '../../service/common.service'
import { StorageService } from '../../service/storage.service'
import { ActivatedRoute } from '@angular/router'

@Component({
  selector: 'app-orderdetail',
  templateUrl: './orderdetail.page.html',
  styleUrls: ['./orderdetail.page.scss'],
})
export class OrderdetailPage implements OnInit {

  
  public userInfo:any;
  public id:string;
  public listdetail:any;
  public contract:string = '';

  constructor(private common:CommonService,private storage:StorageService,public activatedRoute: ActivatedRoute,private changeDetectorRef:ChangeDetectorRef) { 
  }

  ngOnInit() {
    this.activatedRoute.queryParams.subscribe(data=>{
      var dataA = JSON.stringify(data)
      this.id = JSON.parse(dataA).id
      // data.id
      this.changeDetectorRef.detectChanges() 
    })

    this.userInfo = this.common.getInfo()
    this.getUserBuyDetail()

  }
  

   // 购买列表详情
   getUserBuyDetail(){
    var api = '/tbr/getUserBuyDetail'
    var params = {
      userId:this.userInfo.userId,
      id:+this.id
    }
    // alert(this.userInfo.userId)
    // alert(this.id)
    this.common.post(api,params,false).then((res:any)=>{
      console.log(res)
      if(res.code == 200){
        this.listdetail = res.data
        this.changeDetectorRef.detectChanges()
      }
    })
  }

  
}